<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./WEB-INF/template.xhtml">

            <ui:define name="pageTitle">
                Register book
            </ui:define>

            <ui:define name="content">
                <f:view>
                    <h:form>
                        <h1><h:outputText value="Register book"/></h1>
                        <h:panelGrid columns="3">
                            <h:outputLabel value="Name:" for="name" />
                            <h:inputText id="name" value="#{bookBean.b.name}" title="Name" required="true" requiredMessage="The Name field is required."/>
                            <h:message for="name"/>
                            <h:outputLabel value="Publish year:" for="pubDt" />
                            <h:inputText id="pubDt" value="#{bookBean.b.pubDt}" title="PubDt" required="true" requiredMessage="The PubDt field is required.">
                                <f:convertDateTime pattern="yyyy" />
                            </h:inputText>
                            <h:message for="pubDt"/>
                            <h:outputLabel value="Pub:" for="pub" />
                            <h:selectOneMenu id="pub" value="#{bookBean.b.pub}" title="Pub" required="true"
                                             requiredMessage="The Pub field is required." converter="#{publisherConverter}">
                                <f:selectItems value="#{publisherBean.publishers}"/>
                            </h:selectOneMenu>
                            <h:message for="pub"/>
                            <h:outputLabel value="Auth:" for="auth" />
                            <h:selectOneMenu id="auth" value="#{bookBean.b.auth}" title="Auth" required="true"
                                             requiredMessage="The Auth field is required." converter="#{authorConverter}">
                                <f:selectItems value="#{authorBean.authors}"/>
                            </h:selectOneMenu>
                            <h:message for="auth"/>
                        </h:panelGrid>
                        <h:commandButton
                            action="#{redirect.to('books.xhtml')}"
                            actionListener="#{bookBean.create()}"
                            value="Register"/>
                    </h:form>
                </f:view>

            </ui:define>

        </ui:composition>

    </body>
</html>
